model{
 for(i in 1:n){# n is the number of obs
   for(item in 1:k){
     logit(p[i, item]) <- alpha[item] + beta[item]*x[i]
     y[i, item] ~ dbern(p[i,item])
   }

# Latent Variable draw   
   x[i] <- mu[country[i], year[i]]
 }

 sigma ~ dunif(0,1)
 kappa <- pow(sigma, -1)
 for(c in 1:n.country){
  mu[c, 1] ~ dnorm(0, 1)
  for(t in 2:n.year){ #n.year is number of years
   mu[c, t] ~ dnorm(mu[c, t-1], kappa)
  }
 }
 for(item in 1:k){
  beta[item] ~ dgamma(4, 3)
  alpha[item] ~ dnorm(0, .25)
 }
}







